<?php

use Faker\Generator as Faker;

$factory->define(App\loan_customer::class, function (Faker $faker) {
        $moneytype=rand(1,3);
        switch($moneytype){
            case '1';
                $money=rand(1,100000);
                break;
            case '2';
                $money=rand(100000,500000);
                break;
            case '3';
                $money=rand(500000,1000000);
                break;
        }
        $datatype=rand(1,3);
        switch($datatype){
            case '1';
                $date_type=1;
                break;
            case '2';
                $date_type=3;
                break;
            case '3';
                $date_type=5;
                break;
        }
        $limits=$date_type*12;
    if($moneytype==1){
        if($date_type==1){
            $repayments=($money*(1+0.0435))/12;
            $repayment=round($repayments,2);
        }
        if($date_type==3){
            $repayments=($money*(1+0.0475))/36;
            $repayment=round($repayments,2);
        }
        if($date_type==5){
            $repayments=($money*(1+0.05))/60;
            $repayment=round($repayments,2);
        }
    }elseif($moneytype==2){
        if($date_type==1){
            $repayments=($money*(1+0.0445))/12;
            $repayment=round($repayments,2);
        }
        if($date_type==3){
            $repayments=($money*(1+0.0485))/36;
            $repayment=round($repayments,2);
        }
        if($date_type==5){
            $repayments=($money*(1+0.051))/60;
            $repayment=round($repayments,2);
        }
    }else{
        if($date_type==1){
            $repayments=($money*(1+0.0455))/12;
            $repayment=round($repayments,2);
        }
        if($date_type==3){
            $repayments=($money*(1+0.0495))/36;
            $repayment=round($repayments,2);
        }
        if($date_type==5){
            $repayments=($money*(1+0.052))/60;
            $repayment=round($repayments,2);
        }
    }

//    $faker->

    return [
        'money_type'=>$moneytype,
        'money'=>$money,
        'id_per' => str_rands(18, true),
        'name' => $faker->name,
        'email' => $faker->unique()->safeEmail,
        'tel'=>str_rands(11, true),
        'data_type'=>$date_type,
        'status'=>1,
        'step'=>$moneytype,
        'state'=>0,
        'addr' => $faker->address,
        'limits'=>$limits,
        'repayment'=>$repayment,
        'img'=>'',
        'remember_token' => str_random(10),
        'created_at' => \Carbon\Carbon::now()->toDateTimeString(),
        'updated_at' => \Carbon\Carbon::now()->toDateTimeString()
    ];
});
